package com.blockchain.front.servlets.password;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blockchain.framework.service.ServiceSession;
import com.blockchain.front.service.common.PasswordManage;

public class Iphone extends AbstractPasswordServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected boolean mustAuthenticated() {
		return false;
	}

	@Override
	protected void processGet(HttpServletRequest request, HttpServletResponse response, ServiceSession serviceSession)
			throws Throwable {
		processPost(request, response, serviceSession);
	}

	@Override
	protected void processPost(HttpServletRequest request, HttpServletResponse response, ServiceSession serviceSession)
			throws Throwable {
		response.setContentType("text/html;charset=" + getResourceProvider().getCharset());
		PrintWriter out = response.getWriter();
		PasswordManage passwordManage = serviceSession.getService(PasswordManage.class);
		String iphone = request.getParameter("iphone");
		int id = passwordManage.phoneExist(iphone);
		if (id > 0) {
			out.write("1");
		} else {
			out.write("0");
		}
	}

}
